package edu.jd.block_chain.forum.freeChat.dao;

import edu.jd.block_chain.forum.freeChat.FreeChatDto;
import edu.jd.block_chain.forum.freeChat.HostChat;
import edu.jd.block_chain.forum.freeChat.SubChat;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @descriptions:
 * @data: 2021/11/24 20:29
 */
public interface FreeChatDao {
    List<HostChat> getHostChatList(Integer p_id);

    List<SubChat> getSubChatListByHostId(Integer f_c_host_id);
    @Insert("insert into freeChat(f_c_host_id,u_id,p_id,f_c_text,f_c_time) values (#{f_c_host_id},#{u_id},#{p_id},#{f_c_text},#{f_c_time})")
    void addHostChat(FreeChatDto dto);
    @Select("select max(f_c_host_id)+1 from freeChat where p_id=#{p_id}")
    Integer getHostId(Integer p_id);
    @Select("select max(f_c_sub_id)+1 from freeChat where p_id=#{p_id} and f_c_host_id=#{f_c_host_id}")
    Integer getSubId(Integer p_id,Integer f_c_host_id);
    @Insert("insert into freeChat(f_c_host_id,f_c_sub_id,u_id,p_id,f_c_text,f_c_time) values (#{f_c_host_id},#{f_c_sub_id},#{u_id},#{p_id},#{f_c_text},#{f_c_time})")
    void addSubChat(FreeChatDto dto);
}
